/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function agregarTicket(){     
    $("#tablaTicket").hide();
    
    $.ajax(
    {
        type: "GET",
        url: "altaTicketPre",
        async: false,
        dataType: "text",
        beforeSend: function(){
                    
        },
        success: function(transport)
        {
            alert(transport);
            $("#verTicket").html(transport);
            $(".error-inner").hide();
            $("#verTicket").show();
            $("#tablaTicket").hide();
            $('#btnAltaTicket').click(altaTicket);
            $("#btnRegresarTicket").click(mostrarTicket);
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $('#errores').html(xhr.responseText);
            alert(thrownError);
        }            
    });
}

function altaTicket(){  
    $.ajax(
    {
        type: "POST",
        url: "altaTicket",
        async: false,
        dataType: "text",
        data: $('#altaTicket').serialize(),
        beforeSend: function(){
                    
        },
        success: function(transport)
        {           
            $("#body-content").html("");
            $('#menuTicket').trigger('click');
                               
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $('#errores').html(xhr.responseText);
            alert(thrownError);
        }            
    });
    $('#menuTicket').trigger('click');   
    return false;
}

function mostrarTicket(){
    $("#verTicket").hide();   
    $("#tablaTicket").show();
}

function verTicket(){  
    alert("ver");
    $.ajax(
    {
        type: "GET",
        url: "consultaTicket",
        async: false,
        dataType: "text",
        data: "idTicket="+ $(this).closest('tr').attr("id"),       
        beforeSend: function(){
                    
        },
        success: function(transport)
        {
            $("#verTicket").html(transport);
            $("#verTicket").show();
            $("#tablaTicket").hide();
            $("#btnRegresar").click(mostrarTicket);
				
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $('#errores').html(xhr.responseText);
            alert(thrownError);
        }            
    });
}


